package org.benjamin.lending.controller;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.benjamin.lending.domain.entity.RechargeLog;
import org.benjamin.lending.domain.trusteeship.RequestParameter;
import org.benjamin.lending.service.RechargeService;
import org.benjamin.lending.service.TrusteeshipService;
import org.benjamin.lending.utils.CommonsUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;

/**
 * Created by xywen on 2017/5/22.
 */
@Controller
@RequestMapping(value = "recharge")
public class RechargeController {

    public final Logger logger = LogManager.getLogger();

    @Autowired
    private TrusteeshipService trusteeshipService;

    @Autowired
    private RechargeService rechargeService;

    @GetMapping(value = "index")
    public String index(){
        return "recharge.index";
    }

    @RequestMapping(value = "bank_Recharge")
    public String bankRecharge(){
        return "recharge.bankRecharge";
    }

    @RequestMapping(value = "logger")
    public String logger(ModelMap modelMap){
        logger.info("查询充值记录");
        String username = CommonsUtils.getSessionUser();
        Page<RechargeLog> rechargeLogs = this.rechargeService.findLoggerPage(username,new PageRequest(0,10));
        modelMap.addAttribute("rechargeLogs",rechargeLogs);
        return "recharge.logger";
    }


}
